<?php 
  // XXX todo, replace links with autocreated links
  $maxpage = ceil($count/$psize)-1;
  if( $page > 1 ): 
    $pagePrev = $page-1;
    $first = "<a href=\"${_SERVER['PHP_SELF']}?tid=$tid&page=0&psize=${psize}\">[FIRST]</a>";
    $prev = "<a href=\"${_SERVER['PHP_SELF']}?tid=$tid&page=$pagePrev&psize=${psize}\">[PREV]</a>"; 
  else:
    $first = ' [First Page] ';
    $prev = ' [Prev] ';
  endif;
  if( $page < $maxpage ):
    $pageNext = $page+1;
    $next = "<a href=\"${_SERVER['PHP_SELF']}?tid=$tid&page=$pageNext&psize=${psize}\">[NEXT]</a>";
    $last = "<a href=\"${_SERVER['PHP_SELF']}?tid=$tid&page=$maxpage&psize=${psize}\">[LAST]</a>";  
  else:
    $next = ' [NEXT] ';
    $last = ' [LAST] ';
  endif; 
 
echo $first, $prev, $next, $last, '<br /><br />';
?>

